package gameView;

public class Line {
	public double dX, dY;
	public Line(double x1, double y1, double x2, double y2) {
		dX=x2-x1;
		dY=y2-y1;
	}
	public Line(double changeX, double changeY) {
		dX=changeX;
		dY=changeY;
	}
	public Line(double angle, double magnitude, int nothing) {
		dX=magnitude*Math.cos(angle);
		dY=magnitude*Math.sin(angle);
	}
	public Line perpendicularTo() {
		return new Line(dY, -dX);
	}
	public double angle() {
		return Math.atan(dY/dX);
	}
	public double magnitude() {
		return Math.pow(dX*dX+dY*dY, 0.5);
	}
	public Line add(Line tL) {
		return new Line(dX+tL.dX, dY+tL.dY);
	}
	public void checkSign(Line other) {
		double x1, x2, y1, y2;
		x1=dX/magnitude();
		y1=dY/magnitude();
		x2=other.dX/other.magnitude();
		y2=other.dY/other.magnitude();
		if ((new Line(x1, y1, x2, y2)).magnitude()>Math.pow(2, 0.5)) {
			dX=dX*-1;
			dY=dY*-1;
		}
	}
	public Line reverse() {
		return new Line(dX*-1, dY=dY*-1);
	}
}
